#define _CRT_SECURE_NO_WARNINGS

#include "queue.h"

void InitQueue(queue* q)
{
	q->front = 0;
	q->rear = -1;
	q->size = 0;
}
bool IsEmpty(queue* q)
{
	return q->size == 0;
}

bool IsFull(queue* q)
{
	return q->size == MAXSIZE;
}

void Enqueue(queue* q,int value)
{
	if (IsFull(q))
	{
		printf("Queue is full.\n");
		return;
	}
	q->rear++;
	q->data[q->rear] = value;
	q->size++;
}

int Dequeue(queue* q)
{
	if (IsEmpty(q))
	{
		printf("queue is full.\n");
	}
	int value = q->data[q->front];
	q->front++;
	q->size--;
	
	return value;
}

void TraverseQueue(Queue* q)
{
	for (int i = q->front; i < q->rear; i++)
	{
		printf("%d ", q->data[i]);
	}
	printf("\n");
}

void ClearQueue(Queue* q)
{
	q->front = 0;
	q->rear = -1;
	q->size = 0;
}



